<template>
  <view class="option">
    <view class="section">
      <picker
        @change="bindPickerChange"
        :value="index"
        :range="array"
      >
        <view class="picker">
          {{ showStr1 }}
        </view>
      </picker>
    </view>
	<van-picker :columns=" columns " bind:change="onChange"></van-picker>
  </view>
</template>

<script>
// import Toast from '/wxcomponents/vant/dist/toast/index'
const app = getApp();
const imgPrefix = app.globalData.imgUrl + "resourse/";
export default {
  data() {
    return {
        yearArray: [],
		array: [],
		array2: ['上学期', '下学期'],

		showStr1: '选择学年',
		showStr2: '选择学期',
		weight1: true, //选择器权重
		weight2: true,
		btnStat: 0, //0 未选择  1仅选择一个 2全选 允许点击 
		chk: true,
		stype: 0,
        index: '',
		key: 'schInfo',
        token:'',
		stuInfo:[],
		columns: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
    };
  },
//   mounted() {
// 	  this.setArrey1()
//   },
onLoad(){
	// this.setArrey1()
	// var token = uni.getStorageSync("token")
	// console.log(token);
},
onShow(){
	let token = uni.getStorageSync("token");
	console.log(token);
	console.log(this.key);
	let stuInfo = uni.getStorageSync(this.key)
	console.log(stuInfo);
},
  methods: {
	   onChange(event) {
		   console.log(event);
    // const { picker, value, index } = event.detail;
    // Toast(`当前值：${value}, 当前索引：${index}`);
  },
      	bindPickerChange(e) {
              console.log(e);
		if (e.currentTarget.dataset.flag) {
			if (this.weight1) { //权重判断 第一次确认时
				this.weight1 = false,
				this.btnStat = this.btnStat += 1
			}
			this.index = Number(e.detail.value),
			this.showStr1 = this.array[e.detail.value]
		} else {
			if (this.weight2) { //权重判断 第一次确认时
				this.weight2 = false,
				this.btnStat = this.btnStat += 1
			}
			this.index1 = Number(e.detail.value) + 1,
			this.showStr2 = this.array2[e.detail.value]
		}
	},
    	// 根据个人数据更改年份
	setArrey1() {
		let joinYear = Number(this.data.stuInfo.grade);
		let date = new Date();
		let nowYear = date.getFullYear();
		let nowMonth = date.getMonth() + 1;
		var array = [],yearArray = [];
		let step = 0;
		let flag;
		//判断在校时间 
		if (nowYear - joinYear >= 8) {
			console.log("大八了还没毕业？");
			step = 8;
		} else if (nowYear - joinYear <= 8 && nowYear - joinYear >= 0) {
			step = nowYear - joinYear;
			console.log("在校" + step);
		} else {
			console.warn("xxx年份判断异常");
		}
		// 判断上下半年
		if (nowMonth < 8) {
			console.log("上半年");
			flag = nowYear;
		} else {
			console.log("下半年");
			flag = nowYear + 1;
		}
		for (let i = joinYear; i < flag; i++) {
			let str = i + '-' + (i + 1);
			console.log(str);
			array.push(str);
			yearArray.push(i);
		}
		array.reverse();
		yearArray.reverse();
		console.log(array);
		console.log(yearArray);
		this.array = array,
		this.yearArray = yearArray
	},
  },
};
</script>

<style lang="scss" scoped>
</style>